/*
 * Ethan Levine
 * 
 * The contents of this file are subject to the GNU General Public
 * License (GPL) v2.  The full contents of this license can be
 * found at Mathma's website, http://www.codeplex.com/mathma/license
 */

package mathma.core.real.form;

import mathma.core.form.UnaryExpression;
import mathma.core.form.UnknownSuspensionException;

import mathma.core.real.form.MultiplicationExpression;
import mathma.core.real.form.PowerExpression;

import mathma.core.expr.Variable;
import mathma.core.expr.Expression;
import mathma.core.real.FiniteReal;
import mathma.core.real.Real;

/**
 * @since 0.1.2
 * @author Ethan Levine
 */
public class HyperbolicTangentExpression extends UnaryExpression<Real, Real> {

    public HyperbolicTangentExpression(Expression<Real> operand) {
        super(Real.Type, operand);
    }
    
    @Override
    public Real evaluate() {
        return getOperand().evaluate().hyperTangent();
    }
    
    @Override
    public Expression<Real> differentiate(Variable<Real> var) throws UnknownSuspensionException {
        return new MultiplicationExpression(new PowerExpression(
                new HyperbolicSecantExpression(getOperand()), Real.TWO),
                getOperand().differentiate(var));
    }
    
    @Override
    public HyperbolicTangentExpression newUnaryExpression(Expression<Real> expr) {
        return new HyperbolicTangentExpression(expr);
    }
}
